import java.util.Arrays;
import java.util.Random;

public class test {
    //有序数组
    public static void OrderArray(int[] arr){
        for (int i = 0; i < arr.length; i++) {
            arr[i] = i;
        }
    }
    //无序数组
    public static void NorOrderArray(int[] arr){
        Random random = new Random();
        for (int i = 0; i < arr.length; i++) {
            arr[i] = random.nextInt(10_0000);
        }
    }
    //简单数据测试算法是否正确
    public static void testSimple() {
        int[] array = {100,12,5,2,9,10,7,56,0};
//        System.out.println("排序前"+ Arrays.toString(array));
//        Sort.insetsort(array);
//        System.out.println("排序后"+ Arrays.toString(array));
        System.out.println("排序前"+ Arrays.toString(array));
        Sort.SelectsortBetter(array);
        System.out.println("排序后"+ Arrays.toString(array));
        System.out.println("排序前"+ Arrays.toString(array));
        Sort.quickSort(array);
        System.out.println("排序后"+ Arrays.toString(array));
    }

    public static void testOther(){
        int[] arr = new int[1000];
        OrderArray(arr);
        testInserSort(arr);
    }


    public static void testInserSort(int[] arr){
        arr = Arrays.copyOf(arr,arr.length);
        long starttime = System.currentTimeMillis();
        Sort.insetsort(arr);
        long endtime = System.currentTimeMillis();
        System.out.println("直接插入排序运行时间:"+(endtime - starttime));
    }

    public static void testshellSort(int[] arr){
        arr = Arrays.copyOf(arr,arr.length);
        long starttime = System.currentTimeMillis();
        Sort.insetsort(arr);
        long endtime = System.currentTimeMillis();
        System.out.println("直接插入排序运行时间:"+(endtime - starttime));
    }

    public static void testSelectSort(int[] arr){
        arr = Arrays.copyOf(arr,arr.length);
        long starttime = System.currentTimeMillis();
        Sort.Selectsort(arr);
        long endtime = System.currentTimeMillis();
        System.out.println("直接插入排序运行时间:"+(endtime - starttime));
    }

    public static void main(String[] args) {
//        testOther();
        testSimple();

    }
}
